fix(bsk): fix ci

This commit is contained in:
Ljy-0827
2026-08-31 11:50:37 +08:00
committed by GitHub
parent 156ca1c139
commit 7b62bc113e
5 changed files with 30 additions and 23 deletions
@@ -440,7 +440,11 @@ describe("file transfer tools", () => {
totalBytes: 4, totalBytes: 4,
bytesReceived: 0, bytesReceived: 0,
} as chrome.downloads.DownloadItem; } as chrome.downloads.DownloadItem;
const complete = { ...initial, state: "complete", fileSize: 4 } as chrome.downloads.DownloadItem; const complete = {
...initial,
state: "complete",
fileSize: 4,
} as chrome.downloads.DownloadItem;
const downloads: DownloadsApi = { const downloads: DownloadsApi = {
onCreated, onCreated,
onChanged, onChanged,
+4 -2
View File
@@ -298,7 +298,8 @@ export async function captureBrowserDownload(
const triggered = await options.trigger(); const triggered = await options.trigger();
if (isRpcError(triggered)) { if (isRpcError(triggered)) {
void completion.catch(() => undefined); void completion.catch(() => undefined);
const effect: TransferEffectState = capturedId !== undefined ? "committed" : intent ? "unknown" : "none"; const effect: TransferEffectState =
capturedId !== undefined ? "committed" : intent ? "unknown" : "none";
failureResult = { failureResult = {
...triggered, ...triggered,
data: { ...triggered.data, effect_state: effect, phase: "trigger" }, data: { ...triggered.data, effect_state: effect, phase: "trigger" },
@@ -310,7 +311,8 @@ export async function captureBrowserDownload(
succeeded = true; succeeded = true;
return { click, item }; return { click, item };
} catch (err) { } catch (err) {
const effect: TransferEffectState = capturedId !== undefined ? "committed" : click ? "unknown" : "none"; const effect: TransferEffectState =
capturedId !== undefined ? "committed" : click ? "unknown" : "none";
failureResult = captureError( failureResult = captureError(
err instanceof Error ? err.message : String(err), err instanceof Error ? err.message : String(err),
effect, effect,
+1 -5
View File
@@ -4,11 +4,7 @@
import type { SessionManager } from "@/session-manager/manager"; import type { SessionManager } from "@/session-manager/manager";
import type { DownloadParams, DownloadResult, RpcError } from "@/transport/types"; import type { DownloadParams, DownloadResult, RpcError } from "@/transport/types";
import { captureBrowserDownload, chromeDownloadsApi, type DownloadsApi } from "./download-capture"; import { captureBrowserDownload, chromeDownloadsApi, type DownloadsApi } from "./download-capture";
import { import { clickResolvedTarget, type InteractionDeps, resolveActionTarget } from "./interaction";
clickResolvedTarget,
type InteractionDeps,
resolveActionTarget,
} from "./interaction";
import { enforceAgentWindow, isRpcError, lookupSession, resolveTargetTab } from "./shared"; import { enforceAgentWindow, isRpcError, lookupSession, resolveTargetTab } from "./shared";
let downloadActive = false; let downloadActive = false;
@@ -46,7 +46,10 @@ export interface FileInputTransactionResult {
} }
class BoundedWaitError extends Error { class BoundedWaitError extends Error {
constructor(readonly kind: "timeout" | "aborted", message: string) { constructor(
readonly kind: "timeout" | "aborted",
message: string,
) {
super(message); super(message);
} }
} }
@@ -99,7 +102,11 @@ function transferFailure(
return transferError(code, reason, message, { effectState, phase }); return transferError(code, reason, message, { effectState, phase });
} }
function enrichFailure(error: RpcError, effectState: TransferEffectState, phase: UploadPhase): RpcError { function enrichFailure(
error: RpcError,
effectState: TransferEffectState,
phase: UploadPhase,
): RpcError {
return { return {
...error, ...error,
data: { ...error.data, effect_state: effectState, phase }, data: { ...error.data, effect_state: effectState, phase },
@@ -187,10 +194,15 @@ export async function uploadThroughActivatedFileInput(
try { try {
const resolved = await waitBounded( const resolved = await waitBounded(
sendToCdpTarget<{ object?: { objectId?: string } }>(options.cdp, target, "DOM.resolveNode", { sendToCdpTarget<{ object?: { objectId?: string } }>(
backendNodeId: options.actionTarget.backendNodeId, options.cdp,
objectGroup, target,
}), "DOM.resolveNode",
{
backendNodeId: options.actionTarget.backendNodeId,
objectGroup,
},
),
deadline, deadline,
options.signal, options.signal,
"resolving upload trigger timed out", "resolving upload trigger timed out",
@@ -309,10 +321,7 @@ export async function uploadThroughActivatedFileInput(
let backendNodeId: number | undefined; let backendNodeId: number | undefined;
let multiple = summary.multiple; let multiple = summary.multiple;
if (chooser) { if (chooser) {
if ( if (options.actionTarget.frameId && chooser.frameId !== options.actionTarget.frameId) {
options.actionTarget.frameId &&
chooser.frameId !== options.actionTarget.frameId
) {
outcome = transferFailure( outcome = transferFailure(
"unsupported", "unsupported",
"file_input_not_activated", "file_input_not_activated",
+1 -5
View File
@@ -5,11 +5,7 @@
import type { SessionManager } from "@/session-manager/manager"; import type { SessionManager } from "@/session-manager/manager";
import type { RpcError, UploadParams, UploadResult } from "@/transport/types"; import type { RpcError, UploadParams, UploadResult } from "@/transport/types";
import { uploadThroughActivatedFileInput } from "./file-input-transaction"; import { uploadThroughActivatedFileInput } from "./file-input-transaction";
import { import { clickResolvedTarget, type InteractionDeps, resolveActionTarget } from "./interaction";
clickResolvedTarget,
type InteractionDeps,
resolveActionTarget,
} from "./interaction";
import { import {
type CdpRunner, type CdpRunner,
enforceAgentWindow, enforceAgentWindow,