MCPcopy Index your code
hub / github.com/NativeScript/SimDeck / retrySimdeckTextUntil

Function retrySimdeckTextUntil

scripts/integration/cli.mjs:838–869  ·  view source on GitHub ↗
(
  args,
  label,
  predicate,
  failureMessage,
  options = {},
)

Source from the content-addressed store, hash-verified

836}
837
838async function retrySimdeckTextUntil(
839 args,
840 label,
841 predicate,
842 failureMessage,
843 options = {},
844) {
845 const attempts = options.attempts ?? 4;
846 const delayMs = options.delayMs ?? 2_000;
847 let lastDetail = "";
848 for (let attempt = 1; attempt <= attempts; attempt += 1) {
849 try {
850 const output = await retrySimdeckText(args, label, {
851 ...options,
852 attempts: 1,
853 });
854 if (predicate(output)) {
855 return output;
856 }
857 lastDetail = summarizeText(output);
858 } catch (error) {
859 lastDetail = error?.message ?? String(error);
860 }
861 if (attempt < attempts) {
862 logStep(`${label} attempt ${attempt}/${attempts} did not pass; retrying`);
863 await sleep(delayMs);
864 }
865 }
866 throw new Error(
867 `${failureMessage} after ${attempts} attempts:\n${lastDetail}`,
868 );
869}
870
871function looksLikeAgentHierarchy(output) {
872 return output.includes("source:") && output.includes("- ");

Callers 1

mainFunction · 0.85

Calls 4

retrySimdeckTextFunction · 0.85
summarizeTextFunction · 0.85
logStepFunction · 0.85
sleepFunction · 0.70

Tested by

no test coverage detected