CoAgent8 - Source API
    Preparing search index...

    Function acquireSessionTurn

    • Atomically acquires turn ownership on an idle session record.

      Checks cancellation signals and execution budget before lock acquisition, during the lock wait, and across synchronous boundaries immediately after write. Atomic file writes (atomicWrite via fs.rename) represent uninterruptible OS operations; if cancellation occurs across a write boundary, rollback to idle is attempted and turn ownership is revoked. If rollback write fails due to OS I/O error, the record remains until stale recovery reclaims it.

      Parameters

      • handle: string

        Valid session handle.

      • Optionaloptions: number | AbortSignal | BackendReadContext | FileLockOptions

        Optional timeout, cancellation signal, lock options, or read context (EXEC-001-T09c).

      Returns Promise<SessionResult<{ token: string }>>

      Object with ok: true and { token } on success, or { ok: false, error } if busy/expired.

      ToolError if the acquisition wait is aborted or execution budget expired.