Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

787 B
Raw Blame
import type { BrowserActRequest } from '../_generated/extension/src/browser/client-actions.types.js';

/** Resolve the already-selected tab once, including actions inside a batch. */
export function resolveActionTargetIds(
  action: BrowserActRequest,
  requestedTargetId: string | undefined,
  resolvedTargetId: string,
): BrowserActRequest {
  if (action.targetId && action.targetId !== requestedTargetId && action.targetId !== resolvedTargetId) {
    throw new Error('action targetId must match request targetId');
  }
  return action.kind === 'batch'
    ? {
      ...action,
      targetId: resolvedTargetId,
      actions: action.actions.map((nested) => resolveActionTargetIds(nested, requestedTargetId, resolvedTargetId)),
    }
    : { ...action, targetId: resolvedTargetId };
}