Member Junction
    Preparing search index...

    Class MJProgressComputerUseEngine

    The MJ-aware goal engine bound in production. Extends MJComputerUseEngine (prompt-runner routing, vision-model auto-selection, credential resolution, media persistence) and satisfies the ComputerUseGoalRun seam:

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Properties

    AgentRunID?: string

    Parent agent-run id the CDP session sets before Run (links the goal's prompt runs to it).

    AgentRunStepID?: string

    Parent agent-run-step id the CDP session sets before Run (nests child prompt steps under it).

    authHandler: AuthHandler
    browserAdapter: BaseBrowserAdapter
    cancelled: boolean

    Whether Stop() has been called — checked at the top of each step and at the finer-grained checkpoints inside a step.

    ContextUser?: UserInfo

    The MJ user the goal run executes as; the CDP session sets it from the session's context user.

    judge: BaseJudge
    navigationGuard: NavigationGuard
    OnProgress?: (progress: ComputerUseGoalProgress) => void

    Per-step progress hook the CDP session sets before Run (drives live narration).

    toolProvider: ToolProvider

    Accessors

    • get IsStopped(): boolean

      Whether the run has been stopped — by Stop or by its own expiry.

      Exposed because "the engine stopped waiting" and "the engine stopped working" are different things: a step blocked in a page call keeps running after the run is scored, and this is what says whether it has been told to unwind at its next cooperative checkpoint.

      Returns boolean

    • get Provider(): IMetadataProvider

      Optional metadata provider override. Callers should set instance.Provider = providerToUse before invoking Run() in multi-provider contexts. Falls back to the global default provider when unset.

      Returns IMetadataProvider

    • set Provider(value: IMetadataProvider): void

      Parameters

      Returns void

    Methods

    • Self-heal a diverged replay step. Only selector drift is healable here: re-resolve the recorded target's role+name against a fresh element list, with ambiguous cases escalating to the healTargetViaLLM seam and low-confidence matches failing rather than guessing. On a confident match, execute the corrected action, verify the postcondition, rewrite the trace step's selector in place, and return true.

      Flow drift (a failed postcondition) is not selector-healable and returns false, so the run falls back to the LLM tier.

      ReplayHeal: 'off' skips all of this — the step diverges as recorded. 'deterministic' keeps the role+name re-resolution but never asks a model.

      Parameters

      Returns Promise<boolean>

    • LLM heal disambiguation (leg 1b). Overrides the base no-op: when deterministic role+name re-resolution can't uniquely re-find a drifted target, ask the cheap "Computer Use - Heal" prompt which of the CURRENT indexed elements is the intended one, returning { index, confidence }. The caller's shouldAcceptHeal gate (0.6) decides whether to trust it — a low-confidence heal still fails the step rather than guessing.

      Fail-soft everywhere: no heal prompt in metadata, a failed/errored prompt run, or an unparseable response all return confidence 0 — heal then only succeeds on the deterministic path, exactly as before this override existed.

      NOTE: this AIPromptRunner routing mirrors the proven controller/judge path. It runs on the replay-with-heal tier, which the driver dispatch now reaches; the MJ Replay override primes healPromptEntity so this override is live rather than the base confidence-0 no-op. The response parser below is pure + tested.

      Parameters

      Returns Promise<{ confidence: number; index?: number }>

    • Parameters

      • message: string

      Returns void

    • Parameters

      • message: string
      • Optionalerror: unknown

      Returns void

    • Hook for run completion. Currently logs completion status. Can be extended to update agent run records or trigger post-run workflows.

      Parameters

      Returns void

    • Replay a recorded trace on the deterministic tier. The driver dispatch calls this instead of Run when a valid trace exists; the base ComputerUseEngine.Replay owns the full replay/heal/postcondition loop. This override primes the MJ-specific fields the replay tier needs: contextUser, the resolved "Computer Use - Heal" prompt (so healTargetViaLLM can disambiguate a drifted target through AIPromptRunner instead of its confidence-0 no-op), and the "Computer Use - Judge" prompt so the base loop can score the replayed end-state for goal-completion parity with the LLM tier — the driver returns a Completed replay directly with no LLM leg, so the goal verdict must originate here. Run()'s controller/tools setup is deliberately skipped — replay never invokes the controller.

      Returns Promise<ComputerUseResult>

    • Inject a shared judge-verdict cache. When set, the engine reuses a cached verdict for an identical (goal, URL, visible-state) key instead of calling the LLM judge — the cross-attempt generalization of within-run gating. The driver owns the instance so verdicts survive attempt boundaries; unset → no cross-attempt caching (behavior unchanged).

      Parameters

      Returns void

    • Request cancellation of a running run. Cooperative: sets the flag the engine's checkpoints observe AND aborts the shared signal so in-flight LLM calls and settle/backoff delays return promptly. The run unwinds to a Cancelled result within seconds — at the next checkpoint — rather than running the current step to completion.

      Returns void

    • Parse the heal prompt's JSON { index, confidence } response. Pure + static so it is unit-testable without an engine. Tolerant: strips a fenced code block; a missing / non-integer / negative index or non-numeric confidence yields { confidence: 0 } (no disambiguation); confidence is clamped to [0, 1]. A confident heal MUST name an index.

      Parameters

      • raw: string

      Returns { confidence: number; index?: number }